<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>Reverse Ideology</title>
	</head>
	<body>
		<script type="text/javascript">
			function getarg(name) {
				var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
				var r = window.location.search.substr(1).match(reg);
				if (r != null) return decodeURI(r[2]);
				return null;
			}
			var xhr = null, url = getarg('url');
			if (url == null) {
				if (window.stop) window.stop();
				else document.execCommand("Stop");
			}
			if (window.XMLHttpRequest) xhr = new XMLHttpRequest();
			else if (window.ActiveXObject) xhr = new ActiveXObject("Microsoft.XMLHTTP");
			if (xhr != null) {
				xhr.onreadystatechange = function() {
					if (this.readyState == 4 && this.status == 200) {
						conf = JSON.parse(this.responseText);
						console.log(conf["request"]);
						if (conf["request"] == "jsonp") {
							document.write('<script type="text/javascript" src="' + conf["backend"] + '?url=' + encodeURIComponent(url) + '"><\/script>');
						}
					}
				};
				xhr.open("GET", "config.json", true);
				xhr.send();
			}
		</script>
	</body>
</html>
